/*
 * Copyright 2006-2007 the original author or authors.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.google.code.sant;

import org.apache.tools.ant.types.DataType

/**
 * @author Stepan Koltsov
 */
abstract class AntParam

/**
 * @author Stepan Koltsov
 */
abstract class NameValuePairAntParam[T](name: String, value: T) extends AntParam {
  def valueString = value.toString
  
  def toStringString = (name, valueString)
  def toTuple = (name, value)
}

//case class StringAntParam(name: String, value: String) extends NameValuePairAntParam[String](name, value)

case class AnyAntParam(name: String, value: Any) extends NameValuePairAntParam[Any](name, value)

/**
 * @author Stepan Koltsov
 */
class DataTypeAntParam(val dataType: DataType, val name: String) extends AntParam {
  def rename(newName: String) = new DataTypeAntParam(dataType, name)
}

/**
 * @author Stepan Koltsov
 */
class NestedElementAntParam(val name: String, val params: AntParam*) extends AntParam

/**
 * @author Stepan Koltsov
 */
object AntParam {
  implicit def tupleToAntParam(t: (String, Any)) = AnyAntParam(t._1, t._2)
  
  implicit def fileSetToAntParam(fs: supertask.FileSet) = fs.toAntParam
}